﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
using DataAccess.Classes;

namespace Webmau.Admin.Control
{
    public partial class CapTaiKhoan : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnDangNhap_Click(object sender, EventArgs e)
        {
            if (txtTenDangNhap.Text.Length < 7)
            {
                lbThongBao.Text = "Tên đăng nhập >= 7 kí tự";
            }
            else
            {
                if (txtMatKhau.Text.Length < 7)
                {
                    lbThongBao.Text = "Mật khẩu >= 7 kí tự";
                }
                else
                {
                    NguoiDung1 nguoidung = new NguoiDung1();
                    nguoidung.IDNguoiDung = txtTenDangNhap.Text;
                    nguoidung.TenNguoiDung = "member";
                    nguoidung.MatKhau = MaHoaMatKhau.GetMD5(txtMatKhau.Text);
                    if (cbAdmin.Checked == true)
                    {
                        nguoidung.MaNhom = "N01";
                    }
                    if (cbAdmin.Checked == false)
                    {
                        nguoidung.MaNhom = "N02";
                    }
                    nguoidung.NgaySinh = Convert.ToDateTime(DateTime.Now.ToShortDateString().ToString());
                    NguoiDung1.Them(nguoidung);
                    lbThongBao.Text = "Đăng kí thành công!";
                }
            }
        }

    }
}